home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_09
/
1009047a
< prev
next >
Wrap
Text File
|
1992-04-02
|
1KB
|
54 lines
/*** LISTING 4 ***/
/*** ***/
/*** intin.c ***/
/*** **************************************** ***/
/*** INTERRUPT TO HANDLE DATA RECEIVED ***/
/*** **************************************** ***/
#include "serial.h"
extern int portbase;
static char buf[SBUFSIZ];
static int bufptr = 0;
static int byteptr = 0;
extern void (interrupt far *oldvect)();
void interrupt far ReceiveData(void)
{
if((inp(portbase + IIR) & RX_MASK) == RX_ID)
{
buf[bufptr++] = inp(portbase + RXR);
if(bufptr >= SBUFSIZ)
bufptr = 0;
}
/*** Signal end of hardware interrupt ***/
outp(ICR,EOI);
(*oldvect)();
}
/*** **************************************** ***/
/*** GRABS A BYTE FROM BUFFER ***/
/*** **************************************** ***/
int IntSerialIn(void)
{
int Char_Value;
if (byteptr == bufptr)
{
return (-1);
}
Char_Value = (int)buf[byteptr++];
if(byteptr >= SBUFSIZ)
byteptr = 0;
return (Char_Value);
}